home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993 October: Windmill on DISC / ADC Developer CD (1993-10) (''Windmill On DISC'')_iso / Dev.CD Oct 93.iso / System Software / U.S. System Software / System 7 Pro™ Beta 11 / Development Tools / Sample Code / Standard Mail / CollaboDraw (w⁄DigiSign) / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-11  |  3.1 KB  |  201 lines  |  [TEXT/MPS ]

  1. /*-------------------------------------------------------------------------------------
  2.  *
  3.  * Simple Sample AOCE Application Framework
  4.  *
  5.  * ©1991-1993 Apple Computer
  6.  *
  7.  -------------------------------------------------------------------------------------*/
  8. /*
  9.  * main.c -- main entry point and initialization
  10.  *
  11.  * change history:
  12.  *
  13.  * SJF        04/21/93        1.0b2        update to b2
  14.  * SJF        03/01/93        1.0b1        added digital signatures
  15.  * SJF        02/09/93        1.0b1        update to b1
  16.  * SJF        10/13/92        1.0d4        update to a11
  17.  * SJF        09/09/92        1.0d3        update to a9
  18.  * SJF        05/07/92        1.0d2        update to a6
  19.  * SJF        11/06/91        1.0d1        initial coding
  20.  *
  21.  */
  22.  
  23. #ifndef __TRAPS__
  24. #include <Traps.h>
  25. #endif
  26.  
  27. #ifndef __FONTS__
  28. #include <Fonts.h>
  29. #endif
  30.  
  31. #ifndef __MENUS__
  32. #include <Menus.h>
  33. #endif
  34.  
  35. #ifndef __TEXTEDIT__
  36. #include <TextEdit.h>
  37. #endif
  38.  
  39. #ifndef __DIALOGS__
  40. #include <Dialogs.h>
  41. #endif
  42.  
  43. #ifndef __MEMORY__
  44. #include <Memory.h>
  45. #endif
  46.  
  47. #ifndef __PACKAGES__
  48. #include <Packages.h>
  49. #endif
  50.  
  51. #ifndef __TOOLUTILS__
  52. #include <ToolUtils.h>
  53. #endif
  54.  
  55. #ifndef __OSEVENTS__
  56. #include <OSEvents.h>
  57. #endif
  58.  
  59. #ifdef applec
  60. #include <SysEqu.h>
  61. #endif
  62.  
  63. #include "const.h"
  64. #include "mytypes.h"
  65. #include "mymenus.h"
  66. #include "globals.h"
  67. #include "utils.h"
  68. #include "trapavailable.h"
  69. #include "myevents.h"
  70. #include "myaoce.h"
  71. #include "aevt.h"
  72. #include "digisig.h"
  73.  
  74. #include "main.h"
  75.  
  76. /* main entry point */
  77.  
  78. void main(void)
  79. {
  80.     OSErr err;
  81.     
  82.     err = InitToolboxes();
  83.     if (err!=noErr)
  84.         ExitToShell();
  85.     
  86.     err = InitApplication();
  87.     if (err!=noErr)
  88.         ExitToShell();
  89.     
  90.     if (gHasAOCE) {
  91.         err = InitAOCE();
  92.         if (err!=noErr)
  93.             ExitToShell();
  94.         err = InitDigitalSignatures();
  95.         if (err!=noErr)
  96.             ExitToShell();
  97.     }
  98.     
  99.     do
  100.         MainLoop();
  101.     while (!ExitProgram());
  102.  
  103.     if (gHasAOCE)
  104.         ExitDigitalSignatures();
  105.     WritePrefs();
  106.     
  107.     ExitToShell();
  108. }
  109.  
  110.  
  111. /* initializes the standard Mac toolbox */
  112.  
  113. OSErr InitToolboxes(void)
  114. {
  115.     OSErr err;
  116.     
  117.     MaxApplZone();
  118.     MoreMasters();
  119.     MoreMasters();
  120.     MoreMasters();
  121.     InitGraf(&qd.thePort);
  122.     InitFonts();
  123.     InitWindows();
  124.     InitMenus();
  125.     TEInit();
  126.     InitDialogs(nil);
  127.     InitCursor();
  128.     FlushEvents(everyEvent,0L);
  129.     
  130.     if (SupportsAEVT()) {
  131.         RegisterMyEvents();
  132.     }
  133.     
  134.     PrOpen();
  135.     err = PrError();
  136.     PrClose();
  137.     
  138.     if (PrError()!=noErr)
  139.         StopAlert(kNoPrinterAlertID,nil);
  140.         
  141.     return err;
  142. }
  143.  
  144.  
  145. /* initializes the application globals/menus/windows/etc... */
  146.  
  147. OSErr InitApplication(void)
  148. {
  149.     CursHandle cursH;
  150.     
  151.     // global variable initialization
  152.     
  153.     gHasWaitNextEvent = TrapAvailable(_WaitNextEvent);
  154.     gHasAOCE = HasAOCE();
  155.         
  156.     gDone = false;
  157.     gInBackground = false;
  158.     gMenusDirty = false;
  159.     
  160.     cursH = GetCursor(kPencilCursorID);
  161.     gPencilCursor = **cursH;
  162.     cursH = GetCursor(watchCursor);
  163.     gWatchCursor = **cursH;
  164.  
  165.     gNextWindowToMake = 1;
  166.     
  167.     ReadPrefs();
  168.     InitMyMenus();
  169.     InitMyWindows();
  170.     
  171.     ClearAppUndo();
  172.     
  173.     return noErr;
  174. }
  175.  
  176.  
  177. void InitMyMenus(void)
  178. {
  179.     MenuHandle theMenu;
  180.     Handle mbarHandle;
  181.     
  182.     mbarHandle = GetNewMBar(kMenuBar);
  183.     SetMenuBar(mbarHandle);
  184.     
  185.     theMenu = GetMHandle(kAppleMenu);
  186.     AddResMenu(theMenu,'DRVR');            // build apple menu
  187.     
  188.     SetDefaultMenus();
  189.     
  190.     theMenu = GetMHandle(kShapesMenu);
  191.     CheckItem(theMenu,kLineShape,true);
  192.     gCurrentShape = kLineShape;
  193.     
  194.     gMenusDirty = true;
  195. }
  196.  
  197.  
  198. void InitMyWindows(void)
  199. {
  200. }
  201.